#coding=utf-8
from uliweb.form import *
from uliweb.i18n import ugettext_lazy as _

class PollForm(Form):
    selections = StringField(multiple=True)
    
    def form_validate(self, data):
        from uliweb.orm import get_model
        
        Result = get_model('selfdevpoll_user')
        error = {}

        if data.email and (not data.email.endswith('@ccb.com') and not data.email.endswith('@ccbhk.com')):
            error['email'] = '邮件格式不正确，格式为 xxx@ccb.com或xxx@ccbhk.com'
#        row = Result.get((Result.c.email==data.email) & (Result.c.username!=data.username))
#        if row:
#            error['email'] = '邮箱已经被其它人使用！'
        return error

